home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / scope / 001-025 / scopedisk8 / superlib / libsrc.arc / bcmp.asm < prev    next >
Assembly Source File  |  1987-12-22  |  932b  |  44 lines

  1.  
  2. ;BCMP.ASM
  3. ;
  4. ;   If both source and dest are on longword boundries, and if the byte
  5. ;   count is a multiple of 4, then use longword operations.
  6. ;
  7. ;   if byte count < 16 then just use byte operations
  8. ;
  9. ;   BCMP(p1,p2,n)   return 0=failed, 1=compare ok
  10.  
  11.      xdef  _bcmp
  12.  
  13. _bcmp:
  14. movem.l 4(A7),A0/A1;A0 = ptr1, A1 = ptr2
  15. move.l12(A7),D1;# bytes
  16. andi.b#3,15(A7);# bytes multiple of 4?
  17. bneonbyte
  18. andi.b#3,7(A7);ptr1 on lwb?
  19. bneonbyte
  20. andi.b#3,11(A7);ptr2 on lwb?
  21. bneonbyte
  22. lsr.l#2,D1;YES, LONG COMPARE LOOP
  23. clr.lD0;default return. Also sets Z flag
  24. bradropl
  25. looplcmpm.l(A0)+,(A1)+
  26. dropldbne.wD1,loopl
  27. bneend
  28. sub.l#$10000,D1
  29. bplloopl
  30. addq.l#1,D0;return TRUE
  31. rts
  32.  
  33. onbyteclr.lD0;default return. Also sets Z flag
  34. bradropb
  35. loopbcmpm.b(A0)+,(A1)+;BYTE COMPARE
  36. dropbdbne.wD1,loopb;until count exhausted or compare failed
  37. bneend
  38. sub.l#$10000,D1;for buffers >65535
  39. bplloopb;branch to loop because D0.W now is FFFF
  40. addq.l#1,D0;return TRUE
  41. endrts
  42.  
  43.  
  44.